<?php
defined('IN_MAIN') or exit('Invalid Access!');

function calc_personal_sales_print($uid, $date_from, $date_to){
/*
This function will get total personal sales of input uid (user ID).
*/

	global $vars;
	$db=$vars["db"];
	
	$calc_date['start'] = date("Y-m-d H:i:s", strtotime($date_from));
	$calc_date['end'] = date("Y-m-d H:i:s", strtotime($date_to));
	
	$total_sales['bv'] = 0;
	$total_sales['dp'] = 0;
	$total_sales['rp'] = 0;
	$r=mysql_query("select sum(total_bv) as bv, sum(total_dp) as dp, sum(total_rp) as rp from $db->purchase where uid='$uid' and first_sale='y' and no_bv!='y' and status='confirmed' and cdate>='$calc_date[start]' and cdate<='$calc_date[end]'");
	if(@mysql_num_rows($r)){
		$total_sales['bv'] = @mysql_result($r, 0, 'bv');
		$total_sales['dp'] = @mysql_result($r, 0, 'dp');
		$total_sales['rp'] = @mysql_result($r, 0, 'rp');
	}
	
	return $total_sales;
}
?>